package com.my.csv;

import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.text.csv.CsvReader;
import cn.hutool.core.text.csv.CsvUtil;
import com.my.csv.bean.Device;

import java.util.List;

/**
 * @author: marshal
 * @date: 2022-01-11 4:51 PM
 */
public class CsvTest {
    public static void main(String[] args) {
        System.out.println(loadCsv().get(0));
    }

    /**
     * 从整理好的CSV文件中读取数据
     *
     * @return 设备临时数据集合
     */
    private static List<Device> loadCsv() {
        var filename = "device.csv";
        CsvReader csvReader = CsvUtil.getReader();
        List<Device> list = csvReader.read(ResourceUtil.getUtf8Reader(filename), Device.class);
        return list;
    }
}
